/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/*
 *  ======== appThreads.h ========
 *
 *  Threads-wide constants, global variables, macros, 
 *  buffers, and declaration of functions called from the rest of the app
 */
#ifndef APPTHREADS_
#define APPTHREADS_

#include <que.h>

#include "appResources.h"   // application-wide information

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _NTSC
// Captured input frame dimensions
#define CAPF_HEIGHT            240
#define CAPF_WIDTH             352
// Output frame dimensions
#define OPF_HEIGHT             480
#define OPF_WIDTH              720
#elif defined _PAL
// Captured input frame dimensions
#define CAPF_HEIGHT            288
#define CAPF_WIDTH             352
// Output frame dimensions
#define OPF_HEIGHT             576
#define OPF_WIDTH              720
#endif

#define CAPF_SIZE_IN_PIXELS    (CAPF_WIDTH*CAPF_HEIGHT)

// Processed frame dimensions across processing channels
#define PROCF_HEIGHT           (CAPF_HEIGHT)
#define PROCF_WIDTH            (CAPF_WIDTH)
#define PROCF_SIZE_IN_PIXELS   (PROCF_WIDTH*PROCF_HEIGHT)

#define OPF_SIZE_IN_PIXELS     (OPF_HEIGHT*OPF_WIDTH)
#define OPF_PXLSIZE            RGBF_PXLSIZE

// Quadrant offsets according to Cartesian coordinates - one for each Y, CR, and CB
#define Q1_Y_OFFSET    	0
#define Q2_Y_OFFSET    	(OPF_WIDTH >> 1)
#define Q3_Y_OFFSET    	((OPF_WIDTH * OPF_HEIGHT) >> 1)
#define Q4_Y_OFFSET    	((OPF_WIDTH * OPF_HEIGHT >> 1) + (OPF_WIDTH >> 1))

#define Q1_CR_OFFSET	0
#define Q2_CR_OFFSET	(Q2_Y_OFFSET >> 1)
#define Q3_CR_OFFSET	((OPF_WIDTH * OPF_HEIGHT) >> 3) 
#define Q4_CR_OFFSET	Q3_CR_OFFSET + (OPF_WIDTH >> 2)

#define Q1_CB_OFFSET	Q1_CR_OFFSET
#define Q2_CB_OFFSET	Q2_CR_OFFSET
#define Q3_CB_OFFSET	Q3_CR_OFFSET
#define Q4_CB_OFFSET	Q4_CR_OFFSET

// shared scratch memory buckets
enum SSCRBUCKETS {
    VIDEOCAPSCRBUCKET = 0,
    VIDEOPROCSCRBUCKET,
    SCRBUCKETS // total number of shared scratch buckets
    };

// SCOM buffer descriptor
typedef struct ScomCapToProc {
    QUE_Elem elem;
    Char *bufYCRCB[3];
} ScomCapToProc;

typedef struct ScomProcToDisp {
    QUE_Elem elem;
    Char *bufYCRCB[3];
} ScomProcToDisp;

typedef struct placementBuff {
	Char *y;
	Char *cr;
	Char *cb;
} placementBuff;

enum PIXELCOMPONENTS{
	Y = 0,
	CR,
	CB,
	TOTALCOMPONENTS	//total types
};

// control message format
typedef struct CtrlMsg {
    LgUns cmd;                       // Message code
    LgUns arg1;                      // First message argument
    LgUns arg2;                      // Second message argument
} CtrlMsg;

/*
 *  Prototypes for public functions
 */
extern Void appThreadInit();

#ifdef __cplusplus
}
#endif // extern "C" 

#endif // APPTHREADS_  


